/******************************************************************************
COPYRIGHT 2012   : ATECH
Project          : 
Source File Name : lin1Appl.c
Group            : SoftWare Team
Author           : 
Date First Issued: 09/05/2010
********************************Documentation**********************************
Purpose -  This file is 
********************************RevisionHistory********************************
_______________________________________________________________________________
Date : MM/DD/YY    Release        Changes Description                  Author
Date : 09/09/2012    1.0                                                   
   
******************************************************************************/

#define lin1Appl_c



/* #include */
#include <string.h>
#include "Slave_lin1_apis.h"
#include "Slave_lin1_ldf.h"
#include "Slave_lin1_appl.h"
#include "lin1Nwn.h"
#include "lin1Appl.h"
//#include "app_antipinch.h"
//#include "version.h"
//#include "sys_sleep.h"
#include "app_frame_def.h"
#include "hwa_inputs_cfg.h"
#include "hwa_inputs.h"
#include "hwa_outputs_cfg.h"
#include "hwa_outputs.h"
/* static function prototypes */

l_u8 Temp_Blower_upDown=0;
l_u8 Temp_Blower_gap=0;

l_u8 Temp_Temp_upDown=0;
l_u8 Temp_Temp_gap=0;

void lin1_appl_vUpdateTxSignals(void);
void lin1_appl_vParsingRX(void);


/*****************************************************************************/
/**
 * Function Name: void Comm_lin1_vInit(l_u8 baud)
 * Description:   lin system initialization
 *   
 * Param:   none
 * Return:  none
 * Author:  
 *****************************************************************************/
void Comm_lin1_vInit(l_u8 baud)
{
    lin1_sys_init(baud);
    lin1_nwm_init();   
}

/*****************************************************************************/
/**
 * Function Name: void Comm_lin1_vHandler10ms(void)
 * Description:   10ms task
 *
 * Param:   none
 * Return:  none
 * Author: 
 *****************************************************************************/
void Comm_lin1_vHandler10ms(void)
{
    lin1_appl_vUpdateTxSignals();
	lin1_appl_vParsingRX();
    lin1_nwm_vStateMachine1();
    if(LIN1_enNwmState != LIN1_nenNWM_Sleep) lin1_slave_tick();
}

static void lin1_txData(void)
{

//	lin1_u8_wr(ACP_PM2_5_LIN1_TX_DATA1_l_signal_u8_Handle,0x1f);
//	lin1_u8_wr(ACP_PM2_5_LIN1_TX_DATA2_l_signal_u8_Handle,0x03);

}

/*****************************************************************************
 * Function Name: void lin1_hook_vEXTI(void)
 * Description:   wakeup system from static low power mode by external interrupt 
 *
 * Param:   none
 * Return:  none
 * Author:  
 *****************************************************************************/
void lin1_hook_vEXTI(void)
{
//    if (getSleepMode() == TRUE)
//    {   
//        Sys_SetSleepWakeup(); /* wakeup */
//    } 
}

/*****************************************************************************/
/**
 * Function Name: void lin1_appl_vUpdateTxSignals(void)
 * Description:   
 *
 * Param:   none
 * Return:  none
 * Author: 
 *****************************************************************************/
void lin1_appl_vUpdateTxSignals(void)
{
//   lin1_txData();
}

void lin1_appl_vParsingRX(void)
{
#if 0
   l_u8 temp;
   //temp = lin1_u8_rd(ACP_ACP_LIN1_RX_AC_Telltale_Defrost_l_signal_u8_Handle);
   temp = lin1_u8_rd(ACP_ACP_LIN1_RX_AC_Telltale_RearDefrost_l_signal_u8_Handle);
   if(temp==1){
     pwm_key[4].key_pad_on_down_flage=1;//key5
   }else{
	   pwm_key[4].key_pad_on_down_flage=0;
   }
   //temp = lin1_u8_rd(ACP_ACP_LIN1_RX_AC_Telltale_AC_l_signal_u8_Handle);
   temp = lin1_u8_rd(ACP_ACP_LIN1_RX_AC_Telltale_Defrost_l_signal_u8_Handle);
   if(temp==1){
     pwm_key[5].key_pad_on_down_flage=1;//key6
   }else{
	   pwm_key[5].key_pad_on_down_flage=0;
   }
   //temp = lin1_u8_rd(ACP_ACP_LIN1_RX_AC_Telltale_RearDefrost_l_signal_u8_Handle);
   temp = lin1_u8_rd(ACP_ACP_LIN1_RX_AC_Telltale_AC_l_signal_u8_Handle);
   if(temp==1){
     pwm_key[3].key_pad_on_down_flage=1;//key4
   }else{
	   pwm_key[3].key_pad_on_down_flage=0;
   }
   temp = lin1_u8_rd(ACP_ACP_LIN1_RX_AC_Telltale_RecircAir_l_signal_u8_Handle);
   if(temp==1){
     pwm_key[6].key_pad_on_down_flage=1;//key7
   }else{
	 pwm_key[6].key_pad_on_down_flage=0;
   }
   temp = lin1_u8_rd(ACP_ACP_LIN1_RX_AC_KEY_HEAT_l_signal_u8_Handle);
   if(temp==1){
     pwm_key[2].key_pad_on_down_flage=1;//key3
   }else{
	 pwm_key[2].key_pad_on_down_flage=0;
   }
#endif   
}


/***********************end of lin1Appl.c***********************************/

/******************************************************************************
 Revision Notes:

For each change to this file, be sure to record:
1. Who made the change and when the change was made.
2. Why the change was made and the intended result.

  Date     By     Reason For Change
mm/dd/yy  XXX     -----------------

******************************************************************************/
